package net.wangds.yunz.initialize.ctrl;

import net.wangds.yunz.initialize.flow.FlowInitAllRes;
import net.wangds.procengine.flow.FlowContext;
import net.wangds.procengine.flow.FlowEngine;
import net.wangds.procengine.flow.instance.actor.AnonymousActor;
import net.wangds.procengine.flow.instance.context.HashTableContext;
import net.wangds.web.entrypoint.BaseResp;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

import static net.wangds.spring.utils.SpringUtils.getBean;

/**
 * .
 * <p></p>
 *
 * @author 王东石 2020/10/18 8:30.
 */
@RestController
@RequestMapping("/auth/initialize")
public class InitiallizeCtrl {

    @RequestMapping(value = "/all", method = RequestMethod.PUT)
    public BaseResp<Map<String, Object>> initAll() {
        FlowContext ctx = new HashTableContext();
        FlowEngine.start(ctx, new AnonymousActor(), getBean(FlowInitAllRes.class));
        return BaseResp.of(ctx.getBean(FlowInitAllRes.KEY_RES_MAP));
    }

    /*

    @RequestMapping(value = "/systems", method = RequestMethod.PUT)
    public BaseMultipleResp<GeneralResourceEntity> initSystems() {
        FlowContext ctx = new HashTableContext();
        FlowEngine.start(ctx, new AnonymousActor(), getBean(FlowInitSystems.class));
        return BaseMultipleResp.list(ctx.getBean(StepInitSystems.KEY_SYSES));
    }

    @RequestMapping(value = "/applications", method = RequestMethod.PUT)
    public BaseMultipleResp<GeneralResourceEntity> initApplications() {
        FlowContext ctx = new HashTableContext();
        FlowEngine.start(ctx, new AnonymousActor(), getBean(FlowInitApplicatons.class));
        return BaseMultipleResp.list(ctx.getBean(StepInitApplications.KEY_APPS));
    }




    @RequestMapping(value = "/modules", method = RequestMethod.PUT)
    public BaseMultipleResp<GeneralResourceEntity> initModules() {
        FlowContext ctx = new HashTableContext();
        FlowEngine.start(ctx, new AnonymousActor(), getBean(FlowInitModules.class));
        return BaseMultipleResp.list(ctx.getBean(StepInitModules.KEY_MODS));
    }


    @RequestMapping(value="/initMenus", method= RequestMethod.PUT)
    public BaseMultipleResp<SysMenu> initMenus(){
        FlowContext ctx = new HashTableContext();
        FlowEngine.start(ctx, new AnonymousActor(), getBean(FlowInitMenus.class));
        return BaseMultipleResp.list(ctx.getBean(StepInitModules.KEY_MODS));
    }


     */

}
